<?php
/*
 * @ Nguyễn Như Khang
 * nhukhang095@gmail.com
 */
class DBUtils{
   var $db;
   var $ldbname;
   var $ldbhost;
   var $ldbuser;
   var $ldbpass;

   function DBUtils(){       
       global $cfg_dbpass, $cfg_dbname, $cfg_dbhost, $cfg_dbuser;
       $this->ldbhost = $cfg_dbhost;
       $this->ldbname = $cfg_dbname;
       $this->ldbuser = $cfg_dbuser;
       $this->ldbpass = $cfg_dbpass;
   }

    function getConnection(){
        $this->db = mysql_connect($this->ldbhost, $this->ldbuser, $this->ldbpass);
		mysql_select_db($this->ldbname);
        return $this->db;
    }

    function closeConnection(){
          mysql_close($this->db);
    }

    function executeQuery($query){   
		mysql_query("SET names utf8", $this->db);        
        $result = mysql_query($query, $this->db);  
        return $result;
    }

    function getReader($result){
        $rows = mysql_fetch_array($result);
        return $rows;
    }
}
?>